package com.eian.boot.rabbit.core.sender;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback;

public class ConfirmCallbackImpl implements ConfirmCallback {

    private static final Logger logger = LoggerFactory.getLogger(ConfirmCallbackImpl.class);

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        if (!ack) {
            logger.error("消息发送失败 - ID: {}, 原因: {}",
                    correlationData != null ? correlationData.getId() : "null",
                    cause);
        } else {
            logger.debug("消息已确认 - ID: {}",
                    correlationData != null ? correlationData.getId() : "null");
        }
    }
}